﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECS.Demos.Tetris.Systems;
using EntityComponentSystem.Framework;
using EntityComponentSystem.Framework.Math;

namespace ECS.Demos.Tetris.Behavoirs
{
    public class BlockInputBehavior : Behavior<IInputSystem>
    {
        public BlockInputBehavior() : base("input", "block") { }

        protected override Action GetEntityBehavior(IInputSystem system, GameEngine ge, int entity)
        {
            var position = ge.GetComponent(entity, "position");
            return new Action(() =>
            {
                var vector = new Vector2(0, 0);
                
                if (system.AnyKeyDown(ConsoleKey.A, ConsoleKey.LeftArrow)) vector.x -= 1;
                if (system.AnyKeyDown(ConsoleKey.D, ConsoleKey.RightArrow)) vector.x += 1;
                if (system.AnyKeyDown(ConsoleKey.S, ConsoleKey.DownArrow)) vector.y += 1;

                position["x"] += vector.x;
                position["y"] += vector.y;

            });
        }
    }
}
